//
//  TF_PublicityCell.swift
//  TalkfunSDKDemo
//
//  Created by 邓盛明 on 2022/1/25.
//  Copyright © 2022 Talkfun. All rights reserved.
//

import UIKit

class TF_PublicityCell: UITableViewCell {
    var img:UIImageView!
    var titleLab:UILabel!
    var lineView:UIView!
    @objc public var checkBtn:UIButton!
    var saveImg:UIImageView!
    var tf_width:CGFloat!
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.backgroundColor = UIColor.clear
        self.img = UIImageView.init()
        self.contentView.addSubview(self.img)
        
        self.titleLab = UILabel.init()
        self.titleLab.font = UIFont.PingFang(size: 16)
        self.titleLab.textColor = UIColor(red: 0.2, green: 0.21, blue: 0.24,alpha:1)
        self.titleLab.numberOfLines = 2
        self.contentView.addSubview(self.titleLab)
    
        
        self.checkBtn = UIButton.init()
        self.checkBtn.setTitle("查看", for: .normal)
        self.checkBtn.titleLabel?.font = UIFont.PingFang(size: 14)
        self.checkBtn.backgroundColor = UIColor(red: 1, green: 0.37, blue: 0.38, alpha: 1)
        self.checkBtn.layer.cornerRadius = 15;
        self.checkBtn.layer.masksToBounds = true
      
        self.contentView.addSubview(self.checkBtn)
        
        self.lineView = UIView.init()
        self.lineView.backgroundColor = UIColor(red: 0.93, green: 0.93, blue: 0.94, alpha: 1)
        self.contentView.addSubview(self.lineView)
    }
    
  
    func setPopModel(_ model:TFPopupPut) {
        self.titleLab.text = model.title
        let url:URL? = URL.init(string: model.img1)

        self.img.sd_setImage(with: url, placeholderImage: UIImage.init(named: "HTLive.bundle/xuanchuanque"), options: .retryFailed, completed: nil)
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        self.img.frame = CGRect(x: 15, y: 15, width: 57, height: 87)
        self.titleLab.frame = CGRect(x: self.img.frame.maxX+15, y: 15, width: self.frame.width-25-15-self.img.frame.maxX, height: 45)
        self.checkBtn.frame = CGRect(x: self.frame.width-65-25, y: self.frame.height-20-30, width: 65, height: 30)
        self.lineView.frame = CGRect(x: 13, y: self.frame.height-1, width: self.frame.width-25, height: 1)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
